home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
-
- # This should match the mail program on your system.
- $mailprog = '/usr/lib/sendmail';
- # Who do you want the mail to get to who as...
- $recipient = 'DTjanitor\@sgi.com';
-
- #get user home directory from this file
- eval (`cat "/tmp/.userhome_$ENV{'SERVER_PORT'}"`);
-
- #####################################
- # Setup/Define Machine-Specific stuff
- chop($server=`hostname`);
- # make the $userHome/.www_6.0/.DT_DocRootFile, specified below, have it's contents
- # equal to the equivalent-on-your-machine of everything *inside* the
- # single, "'", quotes: '$DocumentRoot="/AbsPath/to/your/DocRoot"'
- $DocumentRoot=$ENV{'DOCUMENT_ROOT'};
- &docroot_failure unless $DocumentRoot;
-
-
- # Print out a content-type for HTTP/1.0 compatibility
- # --the next line tells the browser this doc will be html:
- print "Content-type: text/html\n\n";
-
-
-
- # 1. save out the HTTP env var's we're *REALLY* interested in:
-
- # PATH_* var's are defined in terms of the dir location where
- # the html file is which invokes this cgi-bin script
-
- # PATH_INFO is the "relative path" from Doc root (with a leading `/' char)
- $relpath2parentdir = $ENV{'PATH_INFO'};
- # PATH_TRANSLATED is the absolute path from /
- $abspath2parentdir = $ENV{'PATH_TRANSLATED'};
-
- # QUERY_STRING stores the name of the subdir who's "parent dir" is
- # is the one that PATH_INFO and PATH_TRANSLATED point to.
- $dir2tar = $ENV{'QUERY_STRING'} ;
-
-
- # 2. tack on the ".tar.Z" file suffix for the compressed
- # tar image we're going to create:
- $d2tz = "$dir2tar" . ".tar.Z";
-
-
- # 3. get a pid number for use as the temporary dir we'll create in
- # /WHATEVER/DOCUMENT/ROOT/IS/tmp to hold the compressed tar image file
- # of the actual original dir name:
- $tmpdir = `$DocumentRoot/toolbox/www/cgi-bin/pid` ;
-
-
- # 4. create paths we'll be needing further down and in tarsend-cgi:
-
- # make a "return-them-to-whence-they-came-from" url string:
- # FLAW: this assumes they ALWAYS came from an index.html file
- # AND, the following test covers the special-case of the cgi-bin
- # "index.html" file which can't be in that dir cuz everything in
- # there is executable by the server. so the www/cgi-bin.html file
- # which is in the cgi-bin parent dir, "stands in" as if it were
- # cgi-bin/index.html.... so the following fixes things when that
- # one special case happens to be the one being transmitted.
- if ($dir2tar eq "cgi-bin") {
- $ret2begin = "$relpath2parentdir" . "/cgi-bin.html";
- } else {
- $ret2begin = "$relpath2parentdir" . "/$dir2tar/" . "index.html";
- }
-
- # make absolute path & path/file strings as well as
- # a relative path/file string:
- $abstmpdirpath = "$DocumentRoot/tmp/" . "$tmpdir" ;
- $abstmpdirpathNfile = "$DocumentRoot/tmp/" . "$tmpdir" . "/$d2tz" ;
- $reltmpdirpathNfile = "/tmp/" . "$tmpdir" . "/$d2tz" ;
-
-
- # 5. create the complete set of shell commands to:
- # make the temporary directory
- # change directory to the parent of the dir to tar up
- # create the tar image of dir we want and pipe it to compress
- # then redirecting compress's output to stdout to the absolute
- # temp file/path name:
- chop($cgi_bin = `dirname $0`);
- $maketar = "mkdir $abstmpdirpath; cd $abspath2parentdir; tar cLf - $dir2tar | $cgi_bin/DTcompress > $abstmpdirpathNfile";
-
-
- # 6. run the "maketar" command inside the system() routine
- # (0 == success, non-0 == failure)
- $res = system ("$maketar");
-
-
- # 7. test the result of system to confirm the tmp file was
- # successfully made:
- if ($res == 0) {
-
-
- # we succeeded, so print out success header
- &header_success ;
-
- # 8 get "ls -l" readout for size of this file:
- @list = split(/[ \t\n]+/, `ls -l $abstmpdirpath/$d2tz`);
- if ($#list == 8) {
- $size = $list[4];
- } else {
- $size = $list[3];
- }
- close(LSLONG);
-
- # 9. construct the guts of the anchor pointing to the tmp file:
- $anchor = "\"$reltmpdirpathNfile\"";
-
- # 10. construct the transmit action used in #11:
- $transmitform = "<h2><a href=" . "$anchor>" . "Transmit</a> the compressed tar image</h2>\n";
- $urlline = "<FORM ACTION=\"/toolbox/www/cgi-bin/sendrm-cgi?$abstmpdirpathNfile\" METHOD=\"POST\"> <INPUT TYPE=\"submit\" VALUE=\"Transmit\"> the compressed tar image</FORM><br>\n";
-
- # 11. AND FINALLY, create the final html-crap seen in the body of this doc:
- print "The size of the compressed tar image you are about to transmit is ";
- print "<b>$size BYTES</b><br>";
- print $urlline, "<br>\n";
- print "FYI: <i>Depending on which broswer yer using</i>, when prompted \n";
- print " with the \"Save As\" window, if filename is missing, it's \n";
- print "intended name should be: <h2>$dir2tar.tar</h2>\n";
-
- print "<pre> \n\n </pre>";
-
- } else {
-
- open (INFILE, "> /usr/tmp/tar-cgi.Failure");
- $val = "system call for maketar failed returning: $res\n";
- syswrite(INFILE,$val,length($val));
- syswrite(INFILE,$maketar,length($maketar));
- $val = "\n";
- syswrite(INFILE,$val,length($val));
- close (INFILE);
-
- # we failed, so print out failure header
- &header_failure ;
-
- print "Oh-oh -- something messed-up with the system call ";
- print "to generate the compressed tar archive. \n";
- print "<p>\n";
- print "See <b>/usr/tmp/tar-cgi.Failure</b> for more information.\n";
- print "<p>\n";
- print "pleeze send ";
- print "mail to ";
- print "<a href=\"mailto:DTjanitor\@sgi.com\"><b>DTjanitor\@sgi.com</b> ";
- print "</a>(this link <i>doesn't work</i> in xmosaic)--be sure \n";
- print "to include yer own e-mail address and <i>where you were</i> ";
- print "when you attempted to initiate generation of the compressed ";
- print "tar file. many thanx from the webDT tenderfoot...";
-
- }
-
- print "<hr size=\"6\">\n";
- print "</body>\n";
- print "</html>\n";
-
-
-
-
- # *********************************************************
- # subroutine for successful compressed-tar file generation:
- # lay in the html header/beginning text stuff:
- sub header_success
- {
- print "<html><head><title>DT cgi generation of compressed-tar-file for Entire Dir SUCCESSFUL</title></head><body>";
- print "<h1>Developer Toolbox: Successful Generation of Compressed Tar Image for Entire Directory</h1>";
- &navigator_line
- }
-
- # ************************************************************
- # subroutine header for failed compressed-tar file generation:
- # lay in the html header/beginning text stuff:
- sub header_failure
- {
- print "<html><head><title>DT cgi generation of compressed-tar-file for Entire Dir FAILURE</title></head><body>";
- print "<h1>Developer Toolbox: Failure for Generation of Compressed Tar Image for Entire Directory</h1>";
- &navigator_line
- }
-
-
-
- # *********************************************************
- # subroutine for successful compressed-tar file generation:
- # lay in the html header/beginning text stuff:
- sub navigator_line
- {
- print "<h3><a href=\"/toolbox/DT.html\">HUB</a> | <a \n";
- print "href=\"/toolbox/www/cgi-bin/pheedbak-cgi/toolbox/www/cgi-bin?tar-cgi\">Pheedbak</a> | \n";
- print "<a href=\"/toolbox/DTtree.html\">Tree</a> | \n";
- print "<a href=\"/toolbox/DTtopic.html\">Topic</a> | \n";
- print "<a href=\"/toolbox/DTalfabetic.html\">A-Z</a> | \n";
- print "<a href=\"/toolbox/www/cgi-bin/DTsearch-cgi\">Search</a> | \n";
- print "<a href=\"/toolbox/DThot.html\">Hot</a> | \n";
- print "<a href=\"/toolbox/DTnew.html\">New</a></h3>";
- print "<hr size=\"4\">\n";
- }
-
- sub docroot_failure
- {
- print "<html><head><title>DOCROOT environment variable not set FAILURE</title></head><body>";
- print "<h1>DOCROOT environment variable not set FAILURE</h1>";
- print "<p>\n";
- foreach $f (`env`) {
- print "<br>$f";
- }
- print "<p>\n";
- &navigator_line;
- print "pleeze send ";
- print "mail to ";
- print "<a href=\"mailto:DTjanitor\@sgi.com\"><b>DTjanitor\@sgi.com</b> ";
- print "</a>(this link <i>doesn't work</i> in xmosaic)--be sure \n";
- print "to include yer own e-mail address and <i>where you were</i> ";
- print "when you attempted to initiate generation of the compressed ";
- print "tar file. many thanx from the webDT tenderfoot...";
- exit;
- }
-